package com.vr.cloudpicture.manager.websocket.model.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 图片编辑操作枚举
 *
 * @author hzh
 * @date 2025/05/26
 */
@Getter
@AllArgsConstructor
public enum PictureEditActionEnum {

    INFO("放大操作", "ZOOM_IN"),
    ERROR("缩小操作", "ZOOM_OUT"),
    ENTER_EDIT("左旋操作", "ROTATE_LEFT"),
    EDIT_ACTION("右旋操作", "ROTATE_RIGHT");

    private final String text;
    private final String value;


    /**
     * 根据value获取枚举
     */
    public static PictureEditActionEnum getEnumByValue(String value) {
        if (ObjectUtil.isNull(value)) {
            return null;
        }
        // 这种方式如果枚举值比较多的话，效率不高
        for (PictureEditActionEnum pictureEditActionEnum : PictureEditActionEnum.values()) {
            if (pictureEditActionEnum.getValue().equals(value)) {
                return pictureEditActionEnum;
            }
        }
        return null;
    }
}
